<!-- <template> -->
<!-- <view class="my">
    <button class="login-btn" data-eventsync="true" @tap="getUserInfo">登录</button>
    <button open-type="share">转发到微头条</button>

    <button @tap="openPhoneCall">电话咨询</button>

    <button open-type="getPhoneNumber" @getphonenumber="getPhone">获取手机号</button>
    <button open-type="contact">跳转客服</button>
    <button @tap="authLocation" type="primary" size="mini">申请定位权限</button> -->
<!-- <rate-button order-id="xxx" bind:init="handleInit" bind:success="handleSuccess" /> -->
<!-- </view> -->
<!-- </template> -->

<template>
  <FloatBar />
  <view class="content">
    <view class="topBox">
      <view class="users">
        <view class="u-top">
          <image src="@/static/logo.png" mode="scaleToFill"></image>
          <view class="tit" data-eventsync="true" @tap="getUserInfo"> 登录 / 注册 </view>
        </view>
        <view class="u-bottom">
          <view class="u-item">
            <view class="num">12</view>
            <view class="u-tit">浏览</view>
          </view>
          <view class="u-item">
            <view class="num">12</view>
            <view class="u-tit">浏览</view>
          </view>
          <view class="u-item">
            <view class="num">12</view>
            <view class="u-tit">浏览</view>
          </view>
        </view>
      </view>
    </view>

    <view class="bottomBox">
      <view class="order-all">
        <text class="all-left">所有订单</text>
        <text :class="['all-right', 't-icon', ' t-icon-icon51']"></text>
      </view>

      <view class="order-list">
        <view class="o-item" v-for="(item, index) in orderIconList" :key="index">
          <!-- <image src="../../static/dfk.png" mode="scaleToFill"></image> -->
          <text :class="['t-icon', item.icon]"></text>

          <view class="tit">{{ item.text }}</view>
        </view>
      </view>
    </view>

    <view class="listBox">
      <view class="lists"></view>
    </view>

    <!-- <button open-type="im" data-im-id>跳转客服</button> -->
  </view>
</template>

<script lang="ts" setup>
import { onShareAppMessage } from '@dcloudio/uni-app'
import type { ButtonOnGetphonenumberEvent } from '@uni-helper/uni-app-types/index'
import FloatBar from '@/components/floatBar/floatBar.vue'
import { ref } from 'vue'
const modelValue = ref('')

const changeEvent = (val: string) => {}
// 订单图标渲染
const orderIconList = [
  { type: '1', text: '待付款', icon: 't-icon-payingY' },
  { type: '2', text: '待使用', icon: 't-icon-yizhifu' },
  { type: '3', text: '已完成', icon: 't-icon-yiwancheng' },
  { type: '4', text: '已取消', icon: 't-icon-yiquxiao' },
]

// 获取位置信息
const authLocation = () => {
  tt.authorize({
    scope: 'scope.userLocation',
    success: (res: any) => {
      console.log(res, res.data)
      if (res.data['scope.userLocation'] === 'ok') {
        console.log('您已经授权')
      }
    },
    fail: (err) => {
      console.log(err)
    },
  })
}

// 获取用户信息
const getUserInfo = () => {
  if (uni.getUserProfile) {
    uni.getUserProfile({
      desc: '展示用户信息', // 声明获取 userInfo 的目的，maxAge 在 iOS 中不生效
      success: (res) => {
        console.log(res)
      },
      fail: (fail) => {
        console.log(fail)
      },
      complete: (complete) => {},
    })
  } else {
    uni.showToast({
      title: 'UserProfile不可用',
    })
  }
}

// 抖音分享功能
onShareAppMessage((option: any) => {
  console.log(option, 'ssss')
  return {
    title: '分享订单', // 这是要转发的小程序标题
    desc: '这是默认的转发文案，用户可以直接发送，也可以在发布器内修改',
    path: '/pages/index/index?from=sharebuttonabc&otherkey=othervalue', // ?后面的参数会在转发页面打开时传入onLoad方法
    imageUrl: 'https://e.com/e.png', // 支持本地或远程图片，默认是小程序 icon
    templateId: '这是开发者后台设置的分享素材模板id',
    success() {
      console.log('转发发布器已调起，并不意味着用户转发成功，微头条不提供这个时机的回调')
    },
    fail() {
      console.log('转发发布器调起失败')
    },
  }
})

// 拨打电话
const openPhoneCall = () => {
  uni.makePhoneCall({
    phoneNumber: '12580', //仅为示例
  })
}

// 获取用户手机号时候的回调
const getPhone = (e: ButtonOnGetphonenumberEvent) => {
  console.log(e)
}
</script>

<style scoped lang="scss">
@use './index';
</style>
